/*
 * Copyright (C) Hisilicon Technologies Co., Ltd. 2016-2019. All rights reserved.
 * Description : hi_ssp_st7789.c
 * Author : HiMobileCam Reference Develop Team
 * Create : 2016/11/15
 */
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/fcntl.h>
#include <linux/mm.h>
#include <linux/proc_fs.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <asm/uaccess.h>
#include <linux/delay.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <linux/miscdevice.h>
#include <linux/proc_fs.h>
#include <linux/poll.h>

#include <asm/bitops.h>
#include <asm/uaccess.h>
#include <asm/irq.h>

#include <linux/moduleparam.h>
#include <linux/ioport.h>
#include <linux/interrupt.h>

#include "hi_ssp_d0601024pfd10.h"

#ifdef __HuaweiLite__
#include "asm/io.h"
#include "spi.h"
#else
#include <mach/io.h>/* for IO_ADDRESS */
#endif



void ssp_write_dat_9bit(unsigned char dat)
{
}

void ssp_write_cmd_9bit(unsigned char dat)
{
}

long ssp_lcd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{

    return 0;
}

int ssp_lcd_open(struct inode * inode, struct file * file)
{
        return 0;
}

int ssp_lcd_close(struct inode * inode, struct file * file)
{
    return 0;
}

int ssp_init(void)
{

    return 0;
}

void ssp_deinit(void)
{
    
}


void lcd_reset(void)
{
    

}



void lcd_st7789_init_vertical(void)
{
    
    return;
}



#ifdef __HuaweiLite__
static const struct file_operations_vfs ssp_lcd_fops = {
    ssp_lcd_open,   /* open */
    ssp_lcd_close,  /* close */
    0,              /* read */
    0,              /* write */
    0,              /* seek */
    ssp_lcd_ioctl   /* ioctl */
#ifndef CONFIG_DISABLE_POLL
    , 0             /* poll */
#endif
};

void lcd_sleepin(void)
{
    
}

void lcd_sleepout(void)
{
    
}

int lcd_dev_register(void)
{
    return register_driver("/dev/ssp_lcd", &ssp_lcd_fops, 0666, 0);
}

int lcd_dev_unregister(void)
{
    return unregister_driver("/dev/ssp_lcd");
}


int __init hi_ssp_lcd_init(void)
{
    int ret;
    ret = lcd_dev_register();
    if(ret != 0) {
        printk("Kernel: lcd_dev_register failed!\n");
        return -1;
    }
    lcd_st7789_init_vertical();
    printk("ssp_lcd initial ok!\n");
    return 0;

}

void __exit hi_ssp_lcd_exit(void)
{
    ssp_deinit();
    lcd_dev_unregister();
}

#else

static struct file_operations ssp_lcd_fops = {
    .owner      = THIS_MODULE,
    .unlocked_ioctl = ssp_lcd_ioctl,
    .open       = ssp_lcd_open,
    .release    = ssp_lcd_close
};


static struct miscdevice ssp_lcd_dev = {
   .minor       = MISC_DYNAMIC_MINOR,
   .name        = "ssp_lcd",
   .fops        = &ssp_lcd_fops,
};


static int __init hi_ssp_lcd_init(void)
{
    int ret = 0;
    ret = misc_register(&ssp_lcd_dev);
    if(ret != 0) {
        printk("Kernel: register ssp_0 device failed!\n");
        return -1;
    }
    lcd_st7789_init_vertical();
    printk("ssp_lcd initial ok!\n");
    return 0;
}

static void __exit hi_ssp_lcd_exit(void)
{

    ssp_deinit();
    misc_deregister(&ssp_lcd_dev);
}

module_init(hi_ssp_lcd_init);
module_exit(hi_ssp_lcd_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("hisilicon");
#endif
